package com.yexiao.cofe.business.pojo;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import com.yexiao.core.util.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 参数项
 * eg:温度、甜度
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@TableName("param_item")
public class ParamItem {

    /**
     * 参数项ID
     */
    @TableId(type = IdType.AUTO)
    private int id;

    /**
     * 参数项名称（如甜度、温度）
     */
    @TableField("name")
    private String name;

    /**
     * （单选/多选）。0-单选，1-多选
     */
    @TableField("type")
    private int type;

    /**
     * 是否必选。0-否，1-是
     */
    @TableField("is_required")
    private int isRequired;

    /**
     * 排序权重
     */
    @TableField("sort")
    private int sort;

    public static final String ID = "id";
    public static final String NAME = "name";
    public static final String TYPE = "type";
    public static final String IS_REQUIRED = "is_required";
    public static final String SORT = "sort";

    public static JSONObject getParamItemBaseMsg(ParamItem paramItem) {
        return JSONUtil.of(
                "id", paramItem.getId(),
                "name", paramItem.getName(),
                "type", paramItem.getType(),
                "isRequired", paramItem.getIsRequired(),
                "sort", paramItem.getSort()
        );
    }
}
